A regular expression, which is an object that describes the character pattern. The RegExp class for JavaScript represents regular expressions, and both string and RegExp define methods, which use regular expressions for powerful pattern matching and
In the previous article, an NFA equivalent to a regular expression was obtained, and this article explains how to convert from NFA to DFA and to simplify the DFA and character classes.
I. The representation of the DFA
The representation of the DFA
Regular | repeat
Character classes represented by regular expression syntax
Character class
Matching characters
Example
\d
Numbers from the 0~9
\d\d can match 72, but cannot match 7a or A7
Regular Expressions (regex) are a powerful tool for defining complex queries.
here is a simple information that ignores some of the detailed information.
A regular expression defines a rule for a string. The simplest regular expression does not
CP-Copy (copy) files and directories;
MV-Mobile (move)/rename files and directories;
mkdir-Create a folder (make directories);
RM-Delete (remove) files and directories;
wildcard character (wildcards):
*: Match any character;
?: Match any
Javascript| Regular
A regular expression is an object that describes a character pattern.
JavaScript's RegExp objects and string objects define methods that use regular expressions to perform powerful pattern matching and text retrieval and
Text string for parsing mode
Regular expressions are methods based on text matching patterns--similar to how the compiler generates class files. The compiler finds various patterns in the source code to convert the source-code expression to
First, let's take a look at two special characters: ' ^ ' and ' $ ' they are used to match the start and end of the string, respectively, to illustrate:
"^the": matches a string that starts with "the";
"Of despair$": matches a string ending with
Article Introduction: ECMAScript supports regular expressions by RegExp types.
ECMAScript supports regular expressions by RegExp types.
var expression =/pattern/flags;
the pattern part can be any simple, complex regular
The grep command in a Linux system is a powerful text search tool that uses regular expressions to search for text and print matching rows. The grep full name is global Regular Expression Print, which represents the global regular expression version,
Basic syntax for regular expressionsFirst, let's take a look at two special characters: ' ^ ' and ' $ ' they are used to match the start and end of the string, respectively, to illustrate"^the": matches a string that starts with "the";"Of despair$":
Use of GREP commands in Linux
grep (Global search Regular expression (RE) and print out of the line, a comprehensive search for regular expressions and print out rows) is a powerful text search tool that uses regular expressions to search for text.
PCRE
There are two different ways to use regular expressions in PHP: PCRE (Perl compatible notation, preg_*) function and POSIX (POSIX extended notation, ereg_*) functions. Luckily, the POSIX family function was deprecated from the PHP 5.3.0.
With the regular expression obtained in the previous section, you can use it to construct an NFA. The NFA can easily be converted from regular expressions and also helps to understand the pattern represented by regular expressions.
First, the NFA
The mysql| Regular expression (regex) is a powerful tool for defining complex queries.
Here is a simple information that ignores some of the detailed information.
A regular expression defines a rule for a string. The simplest regular expression does
Ways to define regular expressions
There are two ways to define a regular expression: the constructor definition and the regular expression direct quantity definition. For example:
The code is as follows
var reg1 = new
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.